﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class admin_post : System.Web.UI.Page
{
    DB DBAdmin = new DB();
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        string trim = TextBox3.Text.Replace("\n", "|");
        string[] count = trim.Split('|');
        int isMultiple = 0;
        if (Checkbox1.Checked)
        {
            isMultiple = 1;
        }
        string sqlcon = "insert into voteMaster(voteTitle,votecontent,voteMultiple) values ('" + TextBox1.Text + "','" + TextBox2.Text + "','"+isMultiple +"') SELECT  @@IDENTITY  as  'id'";
        int voteid = Convert.ToInt32(DBAdmin.executeGetReturn(sqlcon));
        for (int i = 0; i < count.Length; i++)
        {
            string iteminsert = "insert into voteDetails(id,voteItem) values ('" + voteid + "','" + count[i].ToString() + "')";
            DBAdmin.executeNonQuery(iteminsert);
        }
        Response.Redirect("mana.aspx");
    }
}
